package org.jakim.entity;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "WORKEXPERIENCE")
public class WorkExperience implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7577187624449284830L;

	@Id
	@GeneratedValue
	@Column(name = "WORKEXPERIENCE_ID")
	private long workId;

	@Column(name = "WORK_START_DATE")
	private Date workStartDate;

	@Column(name = "WORK_END_DATE")
	private Date workEndDate;

	@Column(name = "WORK_OCCUPATION")
	private String workOccupation;

	@Column(name = "WORK_MAIN_ACTIVITIES")
	private String workMainActivities;

	@Column(name = "WORK_EMPLOYER_FIRST_NAME")
	private String employerFirstName;

	@Column(name = "WORK_EMPLOYER_SIR_NAME")
	private String employerSirName;

	@Column(name = "WORK_EMPLOYER_ADDRESS")
	private String employerAddress;

	@Column(name = "WORK_BUSINESS_SECTOR")
	private String workBusinessSector;

	@ManyToOne
	@JoinColumn(name = "PERSONAL_INFO_ID")
	private PersonalInforamation personalInfo;

	public WorkExperience() {

	}

	public WorkExperience(long workId, Date workStartDate, Date workEndDate,
			String workOccupation, String workMainActivities,
			String employerFirstName, String employerSirName,
			String employerAddress, String workBusinessSector,
			PersonalInforamation personalInfo) {
		super();
		this.workId = workId;
		this.workStartDate = workStartDate;
		this.workEndDate = workEndDate;
		this.workOccupation = workOccupation;
		this.workMainActivities = workMainActivities;
		this.employerFirstName = employerFirstName;
		this.employerSirName = employerSirName;
		this.employerAddress = employerAddress;
		this.workBusinessSector = workBusinessSector;
		this.personalInfo = personalInfo;
	}

	public Date getWorkStartDate() {
		return workStartDate;
	}

	public void setWorkStartDate(Date workStartDate) {
		this.workStartDate = workStartDate;
	}

	public Date getWorkEndDate() {
		return workEndDate;
	}

	public void setWorkEndDate(Date workEndDate) {
		this.workEndDate = workEndDate;
	}

	public String getWorkOccupation() {
		return workOccupation;
	}

	public void setWorkOccupation(String workOccupation) {
		this.workOccupation = workOccupation;
	}

	public String getWorkMainActivities() {
		return workMainActivities;
	}

	public void setWorkMainActivities(String workMainActivities) {
		this.workMainActivities = workMainActivities;
	}

	public String getEmployerFirstName() {
		return employerFirstName;
	}

	public void setEmployerFirstName(String employerFirstName) {
		this.employerFirstName = employerFirstName;
	}

	public String getEmployerSirName() {
		return employerSirName;
	}

	public void setEmployerSirName(String employerSirName) {
		this.employerSirName = employerSirName;
	}

	public String getEmployerAddress() {
		return employerAddress;
	}

	public void setEmployerAddress(String employerAddress) {
		this.employerAddress = employerAddress;
	}

	public String getWorkBusinessSector() {
		return workBusinessSector;
	}

	public void setWorkBusinessSector(String workBusinessSector) {
		this.workBusinessSector = workBusinessSector;
	}

	public PersonalInforamation getPersonalInfo() {
		return personalInfo;
	}

	public void setPersonalInfo(PersonalInforamation personalInfo) {
		this.personalInfo = personalInfo;
	}

	public long getWorkId() {
		return workId;
	}
	
	public String getHTMLDates(){
		String htmlDates;
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		
		String endDate = (this.workEndDate != null) ? df.format(this.workEndDate) : "Onwards";
		
		htmlDates = df.format(this.workStartDate);
		htmlDates += " - " + endDate;
		
		return htmlDates;
	}
	
	public String getHtmlEmployerSpec(){
		String htmlEmploySpec;
		
		htmlEmploySpec = this.employerFirstName;
		htmlEmploySpec += " " + this.employerSirName;
		htmlEmploySpec += " " + this.employerAddress;
		
		return htmlEmploySpec;
	}
	
	
	

}
